<!--
* @description 
* @fileName main.vue
* @author huangyu
* @date 2023/02/07 15:45:07
!-->
<template>
    <div>
        <el-form :inline="true">
            <el-form-item>
                <el-input v-model="name" placeholder="请输入物品名称"></el-input>
            </el-form-item>
            <el-form-item label="性别">
                <el-select v-model="sex" style="width:80px">
                    <el-option label="全部" value=""></el-option>
                    <el-option label="男" value="1"></el-option>
                    <el-option label="女" value="2"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="品质">
                <el-select v-model="pinzhi" style="width:80px">
                    <el-option label="全部" value=""></el-option>
                    <el-option label="普通" value="普通"></el-option>
                    <el-option label="散仙" value="散仙"></el-option>
                    <el-option label="真仙" value="真仙"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="物品等级">
                <el-input v-model="levelMin" placeholder="最小" style="width:60px"></el-input>
                <el-input v-model="levelMax" placeholder="最大" style="width:60px"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="getData">查询</el-button>
            </el-form-item>
        </el-form>

        <el-table :data="list" highlight-current-row height="550" border>
            <el-table-column type="index" width="50" label="序号"></el-table-column>
            <el-table-column label="物品名称" prop="name"></el-table-column>
            <el-table-column label="物品等级" prop="level"></el-table-column>
            <el-table-column label="品质" prop="pinzhi"></el-table-column>
            <el-table-column label="类别" prop="typeStr"></el-table-column>
            <el-table-column label="操作" width="200">
                <template slot-scope="scope">
                    <el-button type="primary" plain size="mini" @click="clickChangeData(scope.row)">选择</el-button>
                </template>
            </el-table-column>
        </el-table>

        <pagination
        :total="total"
        :current-page="pageindex"
        :display="pagesize"
        @pagechange="pagechange"
        ></pagination>
    </div>
</template>

<script>
import { get } from '@/common/app.js'
import { classItem } from "@/enum/zhuxian.js"
import pagination from "@/components/common/pagination.vue";
export default {
    components: { pagination },
    props:{
        // 左侧类别id数据
        categoryModel:{},
    },
    data() {
        return {
            classItemList: classItem,
            
            list: [],

            name: "",
            sex: "",
            levelMin: "",
            levelMax: "",
            pinzhi: "",
            className: "",
            type: "",
            pageindex: 1,
            pagesize: 20,
            total: 0,
        }
    },
    mounted() {
        
    },
    methods: {
        clickChangeData(row){
            this.$emit("changeData",row)            
        },
        getData(){
            let params = {
                type: 'getData',
                data: {
                    name: this.name,
                    sex: this.sex,
                    levelMin: this.levelMin,
                    levelMax: this.levelMax,
                    pinzhi: this.pinzhi,
                    class: this.categoryModel.parentId?this.categoryModel.parentId:"",
                    type: this.categoryModel.id,
                    pageIndex: this.pageindex,
                    pageSize: this.pagesize,
                },
            }
            get('game', params).then(res => {
                if (res) {
                    // console.log(res)
                    this.list = res.list
                    this.total = res.total
                }
            })
        },
        pagechange: function(currentPage) {
            this.pageindex = currentPage;
            this.getData();
        },
    },
}
</script>

<style scoped>

</style>